package com.yodawnla.attackTitan2;

import org.anddev.andengine.entity.IEntity;
import org.anddev.andengine.entity.modifier.AlphaModifier;
import org.anddev.andengine.entity.modifier.IEntityModifier.IEntityModifierListener;
import org.anddev.andengine.entity.modifier.SequenceEntityModifier;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.util.MathUtils;
import org.anddev.andengine.util.modifier.IModifier;

public class Blood extends Sprite
{
	IEntityModifierListener mListener;
	
	public Blood(float pX, float pY, TextureRegion pTextureRegion)
	{
		super(pX, pY, pTextureRegion);
		setVisible(false);
		
		mListener = new IEntityModifierListener()
		{
			public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem)
			{
			}

			public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem)
			{
				pItem.setVisible(false);
			}
		};
	}
	
	public void show(float pX, float pY)
	{
		setVisible(true);
		setPosition(pX, pY);
		setScale(0.8f, 1.2f);
		setRotation(MathUtils.random(0, 360));
		clearEntityModifiers();
		registerEntityModifier(new SequenceEntityModifier(mListener,
			new AlphaModifier(5f, 1, 1), new AlphaModifier(2f, 1, 0)
		));
	}
}